package com.jvtd.eyl.data.sp;

import android.content.Context;
import android.content.SharedPreferences;

import com.jvtd.eyl.di.ApplicationContext;
import com.jvtd.eyl.di.PreferenceInfo;

import javax.inject.Inject;
import javax.inject.Singleton;

/**
 * Created by Administrator on 2017/10/16.
 * AppPreferences  -> preferences
 */
@Singleton
public class AppPreferences implements PreferencesHelper
{
  //登录状态
  private static final String KEY_LOGIN_STATE = "LOGIN_STATE";
  //引导页
  private static final String KEY_GUIDE_PAGER = "GUIDE_PAGER";
  //消息推送
  private static String KEY_MY_MESSAGE_JPUSH = "SET_MY_MESSAGE_JPUSH";

  private final SharedPreferences mPreferences;

  @Inject
  public AppPreferences(@ApplicationContext Context context,
                        @PreferenceInfo String fileName)
  {
    mPreferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
  }

  @Override
  public boolean isLogin()
  {
    return mPreferences.getBoolean(KEY_LOGIN_STATE, false);
  }

  @Override
  public void setLogin()
  {
    mPreferences.edit().putBoolean(KEY_LOGIN_STATE, true).apply();
  }

  @Override
  public void clearLogin()
  {
    mPreferences.edit().putBoolean(KEY_LOGIN_STATE, false).apply();
  }

  @Override
  public boolean isStartGuidePager()
  {
    return mPreferences.getBoolean(KEY_GUIDE_PAGER, true);
  }

  @Override
  public void saveGuidePageState()
  {
    mPreferences.edit().putBoolean(KEY_GUIDE_PAGER, false).apply();
  }

}
